<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>

<div class="easyui-layout" fit="true" >
  <t:formvalid formid="myform" dialog="true"  layout="table" action="woController.do?saveProcessWO" beforeSubmit="" >
     <div region="center"   border="0" >
         <table style="width: 100%;%" cellpadding="0" cellspacing="1" border="0" class="formtable" align="center">
	        <tr>
				<td  width="50%" valign="top">
				   <table style="width: 100%;" cellpadding="0" cellspacing="1"  class="formtable" align="center">
					   <tr height="30">
					      <td colspan="4" align="center"><strong>工单受理信息</strong></td>
					   </tr>
					   <tr height="30">
				            <td  width="15%" align="center"><label class="Validform_label">工单编号 </label></td>
							<td  class="value" width="35%" >
							  <input type="hidden" value="${wo.todoId }" name="todoId" id="todoId"/>
					          <input type="hidden" value="${wo.id }" name="id" id="id"/>
					          <input type="hidden" value="${wo.saveState }" name="saveState" id="saveState"/>
					          <input type="hidden" value="${saveProcess.id }" name="processId" id="processId"/>
							  
							  <c:choose>
				              	<c:when test="${empty wo.wo95598Id}">
				              		${wo.id }
				              	</c:when>
				              	<c:otherwise>
				              		${wo.wo95598Id }
				              	</c:otherwise>
				              </c:choose>
				            </td>
							<td  width="15%" align="center"><label class="Validform_label">工单状态 </label></td>
							<td  class="value" width="35%" >
							    ${wo.woStateDesc }
				              
				            </td>
						</tr>
						<tr height="30">
				            <td  width="15%" align="center"><label class="Validform_label">工单类型 </label></td>
							<td  class="value" width="35%" >
							    【${wo.woSrcDesc }】${wo.woTypeDesc } 
				            </td>
							<td  width="15%" align="center"><label class="Validform_label">关联工单</label></td>
							<td  class="value" width="35%" > 
							    <c:choose>
							        <c:when test="${assoList!= null && fn:length(assoList) > 0}">  
							            <c:forEach var="asso" items="${assoList }" >  
									      <a style="cursor:hand;color:#e59687;" onclick="parent.addTab('${asso.assoWoid }');">${asso.assoWoid }</a>
									    </c:forEach>  
							        </c:when>
							        <c:otherwise> 
							                                      无
							        </c:otherwise>
                                </c:choose>
				            </td>
						</tr>
						<tr height="30">
				            <td  width="15%" align="center"><label class="Validform_label">受理时间 </label></td>
							<td  class="value" width="35%" >
							   <c:choose>
				              	  <c:when test="${empty wo.acDatetime}">
				              		 <fmt:formatDate value="${wo.createDatetime}"  type="both" pattern="yyyy.MM.dd HH:mm:ss"/> 
				              	  </c:when>
				              	  <c:otherwise>
				              		 ${wo.acDatetime }
				              	  </c:otherwise>
				                </c:choose>
							    
				            </td>
							<td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">处理时限</label></td>
							<td  class="value" width="35%" > 
						    	<c:choose>
							        <c:when test="${wo.overTime!= null && fn:length(wo.overTime) > 0}">  
							      		  ${wo.overTime }
							        </c:when>
							        <c:otherwise>
							           <input class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" style="width: 180px;cursor:pointer;" id="overTime"
						      				 name="overTime" ignore="ignore" value="${overTime }">
							        </c:otherwise>
							    </c:choose> 
				            </td>
						</tr>
						<tr >
							<td  width="15%" align="center"><label class="Validform_label">受理内容</label></td>
							<td  class="value" width="85%" colspan="3">
				                <textarea style="height:70px;width:100%;border:0px;" name="woContent">${wo.woContent }</textarea>
				            </td>
						</tr>
						<tr height="30">
				            <td  width="15%" align="center"><label class="Validform_label">受理部门</label></td>
							<td  class="value" width="35%" >
							   ${wo.createDepartmentname }
							   
				            </td>
							<td  width="15%" align="center"><label class="Validform_label">受理人员</label></td>
							<td  class="value" width="35%" >
							    ${wo.createRealname }
				            </td>
						</tr>
						
						<tr height="30">
					      <td colspan="4" align="center"><strong>客户基本信息</strong></td>
					    </tr>
					     <tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">客户编号 </label></td>
							<td  class="value" width="35%">
				                ${wo.customerNo }
				            </td>
				            
				            <td width="15%" align="center"><label class="Validform_label">客户名称 </label></td>
							<td class="value" width="35%">
				                ${wo.customerName }
				            </td>
						</tr>
				         <tr height="30">
				            <td width="15%" align="center"><label class="Validform_label">联系人 </label></td>
							<td class="value" width="35%">
				                ${wo.contactMan }
				            </td>
				            <td width="15%" align="center"><label class="Validform_label">联系地址 </label></td>
							<td class="value" width="35%">
				                ${wo.contactAddress }
				            </td>
						</tr>
						<tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">联系电话</label></td>
							<td  class="value" width="35%">
				                 ${wo.contactPhone }
				            </td>
				            <td  width="15%" align="center"><label class="Validform_label">联系电话2 </label></td>
							<td  class="value" width="35%">
				                ${wo.contactPhone2 }
				            </td>				            
						</tr>
						
						
		 <!-- 处理工单Start -->
		 <c:choose>		      
               <c:when test="${isHF==true }"> 
                     <!-- 工单回访Start -->
                     <tr height="30">
					    <td colspan="4" align="center" style="color:#B34D8A"><strong>回访归档</strong></td>
					 </tr>	
					 <tr>
						<td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">满意度评价</label></td>
						<td  class="value" width="85%" colspan="3">			               
			               <select name="woOpinion" id="woOpinion" style="width:155px;">		
					               <option value="满意">满意</option> 
					               <option value="不">不满意</option> 
					               <option value="不评价">不评价</option> 
						   </select>
			            </td>
					</tr>
					<tr>
						<td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">操作选项</label></td>
						<td  class="value" width="85%" colspan="3">			               
			                                                      归档
			                <input type="hidden" value="S00" name="woState" id="woState"/>
			            </td>
					</tr>
					<!-- 工单回访End -->
               </c:when> 
               <c:otherwise>
                       <tr height="30">
					      <td colspan="4" align="center" style="color:#B34D8A"><strong>处理工单</strong></td>
					    </tr>	
					   
					   <!-- 班组用户可见 -->
					    <c:if test="${isTeamMgr==true }">
						    <tr height="30">
								 <td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">处理类型</label></td>
								 <td  width="35%" >
					                 <t:dictSelect field="processType" id="processType" typeGroupCode="procType" hasLabel="false" defaultVal="${saveProcess.processType }" ></t:dictSelect>			              
					             </td>
					             <td  width="15%" align="center">
					                <label class="Validform_label" style="color:#B34D8A">处理户号</label> 
					             </td>
					             <td  width="35%" >
					                <input id="processCustomerNo"  style="width:200px;border:1px;line-height:25px;" maxlength="20" name="processCustomerNo" value="${saveProcess.processCustomerNo }">
					             </td>
					             
							</tr>
							<tr height="30">
								<td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">责任人</label></td>
								<td  width="35%" >
								    <!-- 遍历责任人-->	
					                 <select name="responer" id="responer" style="width:155px;">		
					                     <option value="无">无</option>  
	                            	     <c:forEach var="woResponer" items="${woResponerList }" > 
	                                 	     <option value="${woResponer.responerName }" <c:if test="${saveProcess.responer == woResponer.responerName}">selected</c:if>>${woResponer.responerName }</option>  
						        	     </c:forEach>
						             </select>
                                </td>
								<td  width="15%" align="center">
					                <label class="Validform_label" style="color:#B34D8A">考  &nbsp; 核</label>
					            </td>
					            <td  width="35%">
					                 <select name="isCheck" id="isCheck" style="width:80px;" >	
					                      <option value="否" <c:if test="${saveProcess.isCheck == '否'}">selected</c:if>>否</option> 	
					                      <option value="是" <c:if test="${saveProcess.isCheck == '是'}">selected</c:if>>是</option>  	                            	     
						             </select>
					            </td> 
							</tr>	
						</c:if>		    
						<tr>
							<td  width="15%" align="center"><label class="Validform_label" style="color:#B34D8A">处理意见</label></td>
							<td  class="value" width="85%" colspan="3">
				               <textarea style="height:70px;width:100%;border:0px;" maxlength="500" id="woOpinion" name="woOpinion">${saveProcess.woOpinion }</textarea>
				            </td>
						</tr>
					    <tr height="30">
							<td  width="15%" align="center" ><label class="Validform_label" style="color:#B34D8A">操作选项</label></td>
							<td  class="value" width="100%" colspan="3">
				                 <select name="woState" id="woState" style="width:120px;">
				                    <!-- 遍历工单状态-->			
		                             <c:forEach var="woState" items="${woStateList }" > 
		                                 <c:choose>
		                                    <c:when test="${saveProcess.woOperation!=null }">
		                                    	 <option value="${woState.woStateCode }" <c:if test="${woState.woStateCode == saveProcess.woOperation}">selected</c:if>>${woState.woStateDesc }</option>
		                                    </c:when>
		                                    <c:otherwise>
		                                    	 <option value="${woState.woStateCode }" <c:if test="${woState.woStateCode == defaultState}">selected</c:if>>${woState.woStateDesc }</option>
		                                    </c:otherwise>
		                                 </c:choose>
							            
							         </c:forEach>
						        </select>
						        <span id="selectDeparton" style="display:none">
							        <label style="padding:2px;">主办</label><input id="zDepartname" name="zDepartname" type="text" style="height:30px;width:100px;" readonly="readonly" class="inputxt"   onclick="openZDepartmentSelect();" value="">
			                        <input id="zOrgIds" name="zOrgIds" type="hidden" value="">
			                        <label style="padding:2px;">协办</label><input id="xDepartname" name="xDepartname" type="text" style="height:30px;width:100px;" readonly="readonly" class="inputxt"   onclick="openXDepartmentSelect();" value="">
			                        <input id="xOrgIds" name="xOrgIds" type="hidden" value="">
			                        
		                        </span>
				            </td>   
						</tr>	
						
               </c:otherwise>
         </c:choose>
       
						
				<!-- 处理工单End -->		
						
									
						
					 </table>
				</td>
				
				
				
				<td  width="50%" valign="top">
				    <table style="width: 100%;" cellpadding="0" cellspacing="1"  class="formtable" align="center">
					   <tr height="30">
					      <td colspan="4" align="center"><strong>工单处理流程</strong></td>
					   </tr>
					   <tr >
				          <td colspan="4" align="center" width="50%" valign="top" >
				            <div style="height:245px;overflow-y:scroll;border:none;">
				             <table style="width: 100%;" cellpadding="0" cellspacing="1" class="formtable" align="center">
					             <tr height="30">
					                <td  width="5%" align="center"><strong>序号</strong></td>
						            <td  width="20%" align="center"><strong>流程名称</strong></td>
									<td  width="20%" align="center"><strong>处理部门</strong></td>
									<td  width="20%" align="center"><strong>处理人</strong></td>
									<td  width="25%" align="center"><strong>处理时间</strong></td>
									<td  width="10%" align="center"><strong>用时</strong></td>
								</tr>
			<!-- 遍历处理意见 -->			
			<c:forEach var="process" items="${processList }" varStatus="status">  
				<tr height="30" style="cursor:hand;background:#FFFFFF;" onclick="showWoProcessDetail('${process.id }');" 
				           onmouseover="$(this).css({'background-color':'#CCE6FF'});" onmouseout="$(this).css({'background-color':'#FFFFFF'});">
				    <td   align="center" >${status.count }</td>
				    <td   align="center">${process.woOperadesc }</td>
					<td   align="center" > ${process.createDepartmentname }</td>
					<td   align="center" >${process.createRealname }</td>
					<td   align="center" ><fmt:formatDate value="${process.createDatetime}"  type="both" pattern="yyyy.MM.dd HH:mm:ss"/> </td>
		            <td   align="center" >${process.useHours }</td>
		
				</tr>
			</c:forEach>				                
				             </table>	
				             </div>			           
				          </td>
						</tr>						
					
				    	<tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">用时</label></td>
							<td  class="value" width="35%">
				                 <label id="id_usertime">${USERHOURS }小时</label>
                            </td>
				            
				            <td width="15%" align="center"><label class="Validform_label">${REMAINTITLE} </label></td>
							<td class="value" width="35%">
				                 <label id="id_overplutime">${REMAINTIME }</label>
				            </td>
						</tr>  
						
						<tr height="30">
						    <td colspan="4" align="center"><strong>工单处理详情</strong></td>
						</tr>						
				        <tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">处理部门</label></td>
							<td  class="value" width="35%">
				                 <label id="id_createDepartmentname">${lastWp.createDepartmentname }</label>
                            </td>
				            
				            <td width="15%" align="center"><label class="Validform_label">处理人员 </label></td>
							<td class="value" width="35%">
				                 <label id="id_createRealname">${lastWp.createRealname }</label>
				            </td>
						</tr>
						
						<tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">处理类型</label></td>
							<td  class="value" width="35%">
				                <label id="id_processType">${lastWp.processType }</label>
				            </td>
				            
				            <td width="15%" align="center"><label class="Validform_label">处理户号 </label></td>
							<td class="value" width="35%">
				                 <label id="id_processCustomerNo">${lastWp.processCustomerNo }</label>
				            </td>
						</tr>
						<tr height="30">
							<td  width="15%" align="center"><label class="Validform_label">责任人</label></td>
							<td  class="value" width="35%">
				                <label id="id_responer">${lastWp.responer }</label>
				            </td>
				            <td  width="15%" align="center"><label class="Validform_label">考核</label></td>
							<td  class="value" width="35%">
				                <label id="id_isCheck">${lastWp.isCheck }</label>
				            </td>
				            
						</tr>
						<tr height="30">
							<td width="15%" align="center"><label class="Validform_label">处理时间 </label></td>
							<td class="value" width="85%" colspan="3">
				                 <label id="id_createDatetime">
				                 	<fmt:formatDate value="${lastWp.createDatetime}"  type="both" pattern="yyyy.MM.dd HH:mm:ss"/>
				                 </label>
				            </td>
						</tr>
						<tr>
							<td  width="15%" align="center"><label class="Validform_label">处理意见</label></td>
							<td  class="value" width="85%" colspan="3">
				                <textarea style="height:80px;width:100%;border:0px;" id="id_woOpinion">${lastWp.woOpinion }</textarea>
				            </td>
				         </tr>
					</table>
	            </td>
			</tr>	 
         </table>
	 </div>
   </t:formvalid>
</div>


<script>
	$(function(){
		   if($('#woState').val()=='S03') $('#selectDeparton').show();
		   $('#woState').change(function(){ 
			   var p1=$(this).val();
			   if(p1=='S03'){
				   $('#selectDeparton').show();
			   }else{
				   $('#selectDeparton').hide();
			   }
		   });
		   
		   if($('#responer').val()=='无'){
		 	  $('#isCheck').attr("disabled",true);
		   }
		   $('#responer').change(function(){ 
			   var p1=$(this).val();
			   if(p1=='无'){
				   $('#isCheck').val('无');
				   $('#isCheck').attr("disabled",true);
			   }else{
				   $('#isCheck').val('是');
				   $('#isCheck').attr("disabled",false);
				   
			   }
		   });
		   
	});
	
	function openZDepartmentSelect() {
		$.dialog.setting.zIndex = 9999; 
		
		var orgIds = $("#zOrgIds").val();
		
		$.dialog({content: 'url:departController.do?departSelect&orgIds='+orgIds, zIndex: 2100, title: '组织机构列表', lock: true, width: '400px', height: '350px', opacity: 0.4, button: [
		   {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackZDepartmentSelect, focus: true},
		   {name: '<t:mutiLang langKey="common.cancel"/>', callback: function (){}}
	   ]}).zindex();
	}
	
	function callbackZDepartmentSelect() {
		  var iframe = this.iframe.contentWindow;
		  var treeObj = iframe.$.fn.zTree.getZTreeObj("departSelect");
		  var nodes = treeObj.getCheckedNodes(true);
		  if(nodes.length>0){
		  var ids='',names='';
		  for(i=0;i<nodes.length;i++){
		     var node = nodes[i];
		     ids += node.id+',';
		    names += node.name+',';
		 }
		 $('#zDepartname').val(names);
		 $('#zDepartname').blur();		
		 $('#zOrgIds').val(ids);		
		}
	}
	
	function openXDepartmentSelect() {
		$.dialog.setting.zIndex = 9999; 
		
		var orgIds = $("#xOrgIds").val();
		
		$.dialog({content: 'url:departController.do?departSelect&orgIds='+orgIds, zIndex: 2100, title: '组织机构列表', lock: true, width: '400px', height: '350px', opacity: 0.4, button: [
		   {name: '<t:mutiLang langKey="common.confirm"/>', callback: callbackXDepartmentSelect, focus: true},
		   {name: '<t:mutiLang langKey="common.cancel"/>', callback: function (){}}
	   ]}).zindex();
	}
	
	function callbackXDepartmentSelect() {
		  var iframe = this.iframe.contentWindow;
		  var treeObj = iframe.$.fn.zTree.getZTreeObj("departSelect");
		  var nodes = treeObj.getCheckedNodes(true);
		  if(nodes.length>0){
		  var ids='',names='';
		  for(i=0;i<nodes.length;i++){
		     var node = nodes[i];
		     ids += node.id+',';
		    names += node.name+',';
		 }
		 $('#xDepartname').val(names);
		 $('#xDepartname').blur();		
		 $('#xOrgIds').val(ids);		
		}
	}
	
	function checkForm(){
		 //进行表单验证  
        //如果返回false阻止提交  
        if($('#woOpinion').val().trim()==''){
        	$.messager.alert('&nbsp;&nbsp;信息提醒','请填写处理意见！', 'info');
        	return false;
        } 
        if($('#woState').val()=='S03'){
	        if($('#zOrgIds').val().trim()==''){
	        	$.messager.alert('&nbsp;&nbsp;信息提醒','请选择主办部门！', 'info');
	        	return false;
	        } 
        }
        return true;
	}
	
   function showWoProcessDetail(id){
	   	$.ajax({
			async : false,
			cache : false,
			type : 'GET',
			url : "woController.do?showWoProcessDetail&process_id="+id,
			error : function() {// 请求失败处理函数
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {	
					 $('#id_createDepartmentname').html(d.obj.createDepartmentname);
					 $('#id_createRealname').html(d.obj.createRealname);
					 $('#id_processType').html(d.obj.processType);
					 $('#id_woOpinion').val(d.obj.woOpinion);
					 $('#id_isCheck').html(d.obj.isCheck);
					 
					 $('#id_processCustomerNo').html(d.obj.processCustomerNo);
					 $('#id_responer').html(d.obj.responer);
					 
					 var date = new Date();
					 date.setTime(d.obj.createDatetime);
					 $('#id_createDatetime').html(formatDateTime(date));				
				}    			
			}
		}); 
	   
   }
   
   var formatDateTime = function (date) {  
	    var y = date.getFullYear();  
	    var m = date.getMonth() + 1;  
	    m = m < 10 ? ('0' + m) : m;  
	    var d = date.getDate();  
	    d = d < 10 ? ('0' + d) : d;  
	    var h = date.getHours();  
	    h = h < 10 ? ('0' + h) : h;  
	    var minute = date.getMinutes();  
	    minute = minute < 10 ? ('0' + minute) : minute;  
	    var seconds = date.getSeconds();  
	    seconds = seconds < 10 ? ('0' + seconds) : seconds;  
	    
	    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+seconds;  
	};  
	
</script>